<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="p" value="${param}"></c:set>

<div class="easyui-layout" style="width: 100%; height: 100%;" fit="true">
	<div data-options="region:'center',title:'',split:true"
		style="height: 100%;">
		<form id="form" method="post">
			<table class="detailTable">
			<tr>
				<th>用户名称:</th>
					<td colspan="3" ><input type="text" id="userName" name="userName" style="width:400px;"></td>
					</tr>
				<tr>
					<th>登录名称:</th>
					<td><input type="text" id="loginName" name="loginName"></td>
					<th>用户类别:</th>
					<td><input type="text" name="userType" id="userType"></td>
				</tr>
				<tr>
					<th>登录名称:</th>
					<td><input type="text" id="userId" name="userId"></td>
				</tr>
				<tr>
					<th>邮箱地址:</th>
					<td><input name="email" id="email">
					</td>
					<th>QQ号码:</th>
					<td><input  name="qq" id="qq">
					</td>
				</tr>
				
				<tr>
					<th>电话号码:</th>
					<td><input name="telePhone" id="telePhone">
					</td>
					<th>手机号码:</th>
					<td><input  name="mobilePhone" id="mobilePhone">
					</td>
				</tr>
				
				<tr>
					<th>联系人:</th>
					<td><input name="linkman" id="linkman">
					</td>
					<th>邮政编码:</th>
					<td><input  name="postcode" id="postcode">
					</td>
				</tr>
				
				<tr>
					<th>联系地址:</th>
					<td colspan="3"><input name="address" id="address" style="width:400px;">
				</tr>
				
				<tr>
					<th>备注信息:</th>
					<td colspan="3"><input name="notes" id="notes"style="width:400px;">
				</tr>

				<tr>
					<td colspan="4" align="right">
					<input type="button" onclick="submitForm()" class="button" value="提交" >
					<input type="button" onclick='$("#w_form").dialog("close");' class="button"
						value="关闭">
					</td>
				</tr>
			</table>

		</form>
	</div>
</div>


<script type="text/javascript">
	$(function() {
		userId =<%=request.getParameter("userId")%>;
		$.pmsAjax({
			url : '<c:url value="/user/searchEmCUser.do"/>',
			data : {userId:userId},
			success : function(data) {
				console.log(data);
				if (data) {
					$('#form').form('load', data);
					var str ="";
					switch(data.userType){
					case 1:
						str = "厂家";
						break;
					case 2:
						str = "药店";
						break;
					case 3:
						str = "业务员";
						break;
					}
					$("#userType").val(str);
				} else {
					alertError(data.resultMessage);
				}
			}
		});
	});
	
	function submitForm(){
		$('#form').form('submit', {
		    url:'<c:url value="/user/updateEmCUser.do"/>',
		    onSubmit: function(param){
				switch($("#userType").val()){
				case "厂家":
					str = "1";
					break;
				case "药店":
					str = "2";
					break;
				case "业务员":
					str = "3";
					break;
				}
				$("#userType").val(str);
		    }, 
		    success:function(data){
			    var ret = eval("("+data+")");
		     	if(ret.code=='200'){
		     		parent.alertShow("修改成功");
		     		parent.buyersTable.refresh();
		     		parent.$("#w_buyer_detail").dialog('close');
		     		
			    }else{
			    	alertError(ret.result);
				}
		    }
		});
	}
</script>

